﻿
function getMainPanelData() {
   
    var cHome = '<div id="home" align="center">';
    cHome += '<iframe src="Informasi.htm" frameborder=0 width="100%" height="400">';
    cHome += '</iframe>';
    cHome += '</div>';
    homePanel = new Ext.Panel({
        title: '',
        align: 'center',
        layout: 'column',
        
        cls: '',
        iconCls: '',
        html:cHome ,

        viewConfig: {
            forceFit: true
        }

    });

    homePanel.title = 'Informasi';

    
    var TabAng = new Ext.TabPanel({
       
        activeItem: 0,
      
        shim: false,
        deferredRender: false,
      
        resizeTabs: true,
      
        minTabWidth: 100,
        
        enableTabScroll: true,
       
        defaults: { autoScroll: true },
        items: [homePanel],
        plugins: new Ext.ux.TabCloseMenu()
    });
    mainPage = TabAng;

    var TabContainer = {
        id: 'MainContentPage',
        region: 'center', 
        layout: 'fit',
        margins: '0 0 0 0',
        border: false,
        deferredRender: true,
        items: [TabAng],
        viewConfig: {
            forceFit: true
        }
    };

    return TabContainer;
};

Ext.ux.TabCloseMenu = function() {
    var tabs, menu, ctxItem;
    this.init = function(tp) {
        tabs = tp;
        tabs.on('contextmenu', onContextMenu);
    };

    function onContextMenu(ts, item, e) {
        if (!menu) { 
            menu = new Ext.menu.Menu({
                items: [{
                    id: tabs.id + '-close',
                    text: 'Close Tab',
                    handler: function() {
                        tabs.remove(ctxItem);
                    }
                }, {
                    id: tabs.id + '-close-others',
                    text: 'Close Other Tabs',
                    handler: function() {
                        tabs.items.each(function(item) {
                            if (item.closable && item != ctxItem) {
                                tabs.remove(item);
                            }
                        });
                    }
}]
                });
            }
            ctxItem = item;
            var items = menu.items;
            items.get(tabs.id + '-close').setDisabled(!item.closable);
            var disableOthers = true;
            tabs.items.each(function() {
                if (this != item && this.closable) {
                    disableOthers = false;
                    return false;
                }
            });
            items.get(tabs.id + '-close-others').setDisabled(disableOthers);
            e.stopEvent();
            menu.showAt(e.getPoint());
        }
    };